﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Linq;

using ProjectBase.Core;
using $prjsn$.Entity;

namespace $safeprojectname$
{
    public class CodeListFilterValidator : FilterValidatorBase<CodeList, CodeListFilter, int>
    {
        protected override void Init(RuleCollection<CodeListFilter> rules)
        {
            base.Init(rules);
        }
    }

    public class CodeListValidator<TEntity, TDao> : EntityValidatorBase<TEntity, int, TDao>
        where TEntity : class, ICodeList
        where TDao : class, IReadDao<TEntity, int>
    {
        private static readonly IList<string> _ignoredProperties = new List<string> { "ProfileId" };

        protected override void Init(RuleCollection<TEntity> rules)
        {
            // TODO
        }

        #region MetaData

        protected override void EnrichMetaDataAttribute(MDAttribute attribute, MetaDataMessage metaData)
        {
            base.EnrichMetaDataAttribute(attribute, metaData);

            var haveNoCode = attribute.Name.IsEqual("Code")
                             && typeof(TEntity).HasType<IHaveNoCode>();
            if (haveNoCode)
            {
                attribute.CanEdit = false;
                attribute.CanRead = false;
                attribute.CanQuery = false;
            }
        }

        protected override IList<string> AllwaysIgnoredProperties
        {
            get { return _ignoredProperties.Append(base.AllwaysIgnoredProperties); }
        }

        #endregion MetaData
    }
}